package main

import (
	"go.manyji.com/lib/config"
	"go.manyji.com/lib/log"
	_ "go.manyji.com/lib/log/filelog"
	"go.manyji.com/lib/systemd"
	"net/http"
	"os"
	"path/filepath"
	pkgApp "sieve_admin_server/app"
	"sieve_admin_server/app/server"

	"go.manyji.com/lib/app"
	_ "net/http/pprof"
)

var (
	fSystemd = config.String("systemd.name", filepath.Base(os.Args[0]), "systemd name")
	// fSessExpire = config.Int("session.expire", 3600, "session过期时间 秒")
)

func init() {
	app.OnStart(func() {
		if err := systemd.AutoStart(*fSystemd); err != nil {
			log.Info("systemd.AutoStart:", *fSystemd, err)
		}
		log.Info(pkgApp.InitApp())
	})
}

func main() {
	app.Start()
	http.HandleFunc("/debug/db/", pkgApp.HandleStats)
	http.HandleFunc("/exclude/", pkgApp.HandleExclude)
	server.LogIn(pkgApp.Login)
	server.LogOut(pkgApp.Logout)
	if err := server.Run(); err != nil {
		log.Err(err)
	}
}
